package com.xnyzc.lhy.common.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: huxuekuo
 * @Date: 2019-07-29 18:19
 * @Description:
 */
@NoArgsConstructor
@Data
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class GouldResult {
    @ApiModelProperty(value = "状态码")
    private String status;
    @ApiModelProperty(value = "信息")
    private String info;
    @ApiModelProperty(value = "信息码")
    private String infocode;
    @ApiModelProperty(value = "具体结构集")
    private List<Results> results;
    private String count;
    private RouteBean route;
    private AreaInfo regeocode;

    @NoArgsConstructor
    @Data
    public static class AreaInfo{
        private String formatted_address;
        private Compoment addressComponent;

        @NoArgsConstructor
        @Data
        public static class Compoment{
            private String country;
            private String province;
            private ArrayList city;
            private String citycode;//城市编码
            private String district;//区县名称
            private String adcode;//行政编码
            private String township;//街道名称
            private String towncode;//街道编码 110105026000  北京110-朝阳区105-望京街道026000

        }
    }

    @NoArgsConstructor
    @Data
    public static class RouteBean {
        private String origin;
        private String destination;
        private List<PathsBean> paths;
        private String sAcode;
        private String eAcode;


        @NoArgsConstructor
        @Data
        public static class PathsBean {
            private String distance;
            private String duration;
            private String strategy;
            private String tolls;
            //            private String toll_distance;
//            private String restriction;
//            private String traffic_lights;
            private List<StepsBean> steps;

            @Data
            public static class StepsBean {
                private String polyline;
//                private String instruction;
//                private String orientation;
//                private String distance;
//                private String tolls;
//                private String toll_distance;
//                private String duration;
//                private String action;
//                private String road;
//                private List<String> toll_road;
            }
        }
    }


    @Data
    @ToString
    public class Results {
        @ApiModelProperty(value = "起点ID")
        private String origin_id;
        @ApiModelProperty(value = "终点ID")
        private String dest_id;
        @ApiModelProperty(value = "距离")
        private String distance;
        @ApiModelProperty(value = "期间")
        private String duration;
    }

    public Double getTotalDistance() {
        double distance = 0.0;
        if (null != this.getResults()) {
            for (Results result : this.getResults()) {
                distance += Double.valueOf(result.distance);
            }
        }
        return distance;
    }
}
